<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改公司信息')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form class="form-horizontal" id="form-user-edit" th:object="${company}">
        <input name="tableId" type="hidden" th:field="*{tableId}"/>
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">收购公司：</label>
                    <div class="col-sm-8">
                        <input name="userName" placeholder="請輸入收购公司" class="form-control" type="text" maxlength="30"
                               th:field="*{companyName}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">收购品名：</label>
                    <div class="col-sm-8">
                        <input name="userName" placeholder="請輸入收购品名" class="form-control" type="text" maxlength="30"
                               th:field="*{receiptMaterial}" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">收購總量：</label>
                    <div class="col-sm-8">
                        <input name="userName" placeholder="請輸入收購總量" class="form-control" type="text" maxlength="30"
                               th:field="*{receiptNum}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">合同信息：</label>
                    <div class="col-sm-8">
                        <input name="receiptContract" placeholder="請選擇合同信息" class="form-control" type="file" maxlength="30"
                               th:field="*{receiptContract}">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">合同協議號：</label>
                    <div class="col-sm-8">
                        <input name="contractNo" placeholder="請輸入合同協議號" class="form-control" type="text" maxlength="30"
                               th:field="*{contractNo}" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">商品編碼：</label>
                    <div class="col-sm-8">
                        <input name="saleNo" placeholder="請輸入商品編碼" class="form-control" type="text" maxlength="30"
                               th:field="*{saleNo}">
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">合同有效期：</label>
                    <div class="col-sm-8">
                        <input name="recordId" placeholder="請輸入合同有效期" class="form-control" type="text" maxlength="30"
                               th:field="*{contractTime}" disabled>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">合同預覽：</label>
                    <div class="col-sm-8">
                        <img th:src="*{receiptContract}" width="100" height="100" class="img-thumbnail">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">單位：</label>
                    <div class="col-sm-8">
                        <select name="unit" class="form-control m-b"
                                th:with="type=${@dict.getType('sys_leftover_unit')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                                    th:field="*{unit}" required></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">
    var prefix = ctx + "system/company";

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-user-edit").serializeArray();
            // var state = $("input[id='state']").is(':checked') == true ? 0 : 1;
            // var roleIds = $.form.selectCheckeds("role");
            // var postIds = $.form.selectSelects("post");
            // data.push({"name": "state", "value": state});
            // data.push({"name": "roleIds", "value": roleIds});
            // data.push({"name": "postIds", "value": postIds});
            $.operate.saveTab(prefix + "/edit", data);
        }
    }

    /* 用户管理-修改-选择部门树 */
    function selectDeptTree() {
        var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero) {
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }

    $(function () {
        $('#post').select2({
            placeholder: "请选择岗位",
            allowClear: true
        });
    })
</script>
</body>
</html>